


#
# Makefile for basic ICMP example
#

SHELL = /bin/sh

#----------------------------------------------------------- SETUP

TOPDIR = ../..
include $(TOPDIR)/Makefile.common

JAVACOPTIONS =
JAVAOPTIONS  = -Xms36m

JAVAC = javac -classpath .:$(SSFNET_TEST_CLASSPATH)
JAVA  = java $(JAVAOPTIONS) -classpath .:$(SSFNET_TEST_CLASSPATH)

SCHEMAS = $(TOPDIR)/examples/net.dml

#----------------------------------------------------------- MAKE EXAMPLE

all: classes pingtest tracetest

classes:
	$(JAVAC) *.java

pingtest:
	@echo ''
	@echo '---------------  PING EXAMPLE --------------------'
	$(JAVA) SSF.Net.Net 200 pingTest.dml $(SCHEMAS) > pingTest-raw.out 2>&1
	@echo '    Reading SSFNET simulation output ...'
	@rm -f .successes.out
	@rm -f .sorted.out
	@grep received pingTest-raw.out > .successes.out
	@sort -n .successes.out > .sorted.out
	@echo '    Verifying SSFNET simulation output ...'
	@if [ -z "`diff .pingTest.verify .sorted.out`" ]; \
	then \
	 echo '    Verification complete!'; \
	else \
	 echo '    Uh oh!  Verification failed!'; \
	fi
	@rm -f .successes.out
	@rm -f .sorted.out

tracetest:
	@echo ''
	@echo '--------------- TRACEROUTE EXAMPLE --------------------'
	$(JAVA) SSF.Net.Net 250 tracerouteTest.dml $(SCHEMAS) > tracerouteTest-raw.out 2>&1
	@echo '    Reading SSFNET simulation output ...'
	@rm -f .successes.out
	@rm -f .sorted.out
	@grep 'ms ' tracerouteTest-raw.out > .successes.out
	@sort -n .successes.out > .sorted.out
	@echo '    Verifying SSFNET simulation output ...'
	@if [ -z "`diff .tracerouteTest.verify .sorted.out`" ]; \
	then \
	 echo '    Verification complete!'; \
	else \
	 echo '    Uh oh!  Verification failed!'; \
	fi
	@rm -f .successes.out
	@rm -f .sorted.out

clean:
	@rm -f .successes.out .sorted.out *-raw.out *.class
	@echo 'Done.'

spotless: clean
	@find . \( -name "*.class" -o -name ".*~" -o -name "*~" \) -exec rm -f {} \;
	@echo 'Done.'
